const Router = require('koa-router'); 
const router = new Router({prefix:'/questions'});
const { find, checkTopicExist ,findById, create, update, delete:del, checkQuestioner} = require("../controllers/questions");
//自己编写的中间件
// const jsonwebtoken = require('jsonwebtoken');
const jwt = require('koa-jwt');
const { secret } = require('../config');

//使用插件
const auth = jwt({ secret })
router.get('/',find)
router.get('/:id',checkTopicExist,findById)
router.post('/', auth, create)
router.post('/modify/:id', auth ,checkTopicExist,checkQuestioner,update)
router.delete('/:id', auth ,checkTopicExist,checkQuestioner,del)



module.exports = router;